﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;

namespace NetCoreExceptionIntroduce
{
    public class SomeActionFilter : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            var loggerFactory = (ILoggerFactory)context.HttpContext.RequestServices.GetService(typeof(ILoggerFactory));
            var logger = loggerFactory.CreateLogger<SomeActionFilter>();
            logger.LogInformation($"Action ${context.ActionDescriptor.DisplayName} OnActionExecuting");
            base.OnActionExecuting(context);
        }
    }
}
